package net.jxta.myjxta.ui;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;

import net.jxta.peergroup.PeerGroup;

public class ChatFrame extends JFrame {
	
	public static boolean isVisible=false;
	
	public ChatFrame(JPanel p){
		setTitle("Group Chat");
		setSize(500,500);
		Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); 
	    Dimension frameSize=this.getSize();
		if(frameSize.height>screenSize.height) frameSize.height=screenSize.height; 
        if(frameSize.width>screenSize.width) frameSize.width=screenSize.width; 
        setLocation((screenSize.width-frameSize.width)/2, (screenSize.height-frameSize.height)/2); 
        
        
        setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent e)
			{
				setVisible(false);
			}
		});
        
        
        add(p);
        
	}

	public void setVisible(boolean visible){
		isVisible=visible;
		super.setVisible(visible);
	}
	
	public boolean isVisible(){
		return isVisible;
	}
}
